import { defineStore } from 'pinia'
import { getUserInfoApi } from '@/api'

export const useUserInfo = defineStore('userInfo', {
    state: () => {
        return {
            openid: '',
            nickname: '',
            avatar: ''
        }
    },
    actions: {
        async getUserInfo() {
            const { data } = await getUserInfoApi()
            const { openid, nickname, avatar } = data
            this.openid = openid
            this.nickname = nickname
            this.avatar = avatar
        }
    }
})